﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace Rezene.Web.Business.Amazon.Entities
{
    public class S3BaseObject
    {
        public string Name { get; set; }
        public string Path { get; set; }
        public string Bucket { get; set; }
        public string Title { get; set; }
        public bool Show { get; set; }

        [JsonIgnore]
        public string AmazonPath
        {
            get
            {
                var path = string.IsNullOrEmpty(Path) ? Path : Path.EndsWith("/") ? Path : Path + "/";
                if (!string.IsNullOrEmpty(path) && path.StartsWith("/"))
                {
                    path = path.Substring(1);
                }
                return path + Name;
            }
        }

        [JsonIgnore]
        public string AmazonPublicPath
        {
            get
            {
                return $"{Bucket}.s3.amazonaws.com/{AmazonPath}";
            }
        }
    }
}